{extend name="ashippingmanagement2/Public/base" /}
{block name="container"}
        <!-- 标题 -->
    <div class="page-heade">
      <h2 class="title_color text-center">二级出货管理</h2>
    </div>
    <!-- 标题 -->
    <table class="table table-bordered" style="margin:0">
      <tr>
        <td>
        <a href="{:url('ashippingmanagement2/addP')}" class="btn btn-sm btn-info">新增二级出货</a>
        <span class="lr_5"></span>
         <a href="{:url('ashippingmanagement2/import')}" class="btn btn-sm btn-info J_menuItem">导入二级出货</a>
        </td>
      </tr>
    </table>
    <div class="row-margin-top">
    <form id="form_id" action=""  class="form-inline" method="post">
      <table class="row-margin-top tab-content table-bordered  table" border="1">
          <tr>
            <td style="min-width: 120px;width: 120px"><label for="" class="form-label">系统名称</label></td>
            <td><input type="text" class="form-control" name="d.title" value="<?php if(isset($where['d_title'])) echo $where['d_title']; ?>"></td>
            <td style="min-width: 120px;width: 120px"><label for="" class="form-label">经销商名称</label></td>
            <td><input type="text" class="form-control" name="b.title" value="<?php if(isset($where['b_title'])) echo $where['b_title']; ?>"></td>
              <td style="min-width: 120px;width: 120px"><label for="" class="form-label">网点名称</label></td>
            <td><input type="text" class="form-control" name="c.title" value="<?php if(isset($where['c_title'])) echo $where['c_title']; ?>"></td>
            </tr>
            <tr>
             <td style="min-width: 120px;width: 120px"><label for="" class="form-label">产品名称</label></td>
            <td><input type="text" class="form-control" name="e.pro_name" value="<?php if(isset($where['e_pro_name'])) echo $where['e_pro_name']; ?>"></td>
            <td style="min-width: 120px;width: 120px"><label for="" class="form-label">销售人员</label></td>
            <td><input type="text" class="form-control" name="f.em_name" value="<?php if(isset($where['f_em_name'])) echo $where['f_em_name']; ?>"></td>
             <td style="min-width: 120px;width: 120px"><label for="" class="form-label">日期</label></td>
            <td colspan="2">
                 <div class="form-group">
            <input type="text" id="start" class="form-control layer-date " style="width: 120px;min-width: 120px; display: inline-block;" name="a.fy2Date" value="<?php if(isset($where['a_fy2Date'])) echo $where['a_fy2Date']; ?>">
           </div>
            <div class="form-group">
                至
            </div>
           <div class="form-group">
            <input type="text" class="form-control layer-date" style="width: 120px;min-width: 120px;display: inline-block;" id="end" name="a.fy2Date1" value="<?php if(isset($where['a_fy2Date1'])) echo $where['a_fy2Date1']; ?>">
           </div>
            </td>
            </tr>
             <tr>
              <td colspan="6" class="text-center">
              <button class="btn btn-info query" type="submit">查询</button>
              <button class="btn btn-info emptyIf" type="submit" onclick="$('#form_id').find('input').val('');">清空</button>
              <button class="btn btn-info LendExcel" type="button" onclick='window.open("/index/Ashippingmanagement2/export","_self")'>导出Excel</button>
            </td>
            </tr>
      </table>
      <table class="table table-striped table-bordered table-hover text-center" id="verifytable">
      	 <tr>
			<th colspan="17"><button class="btn-info btn" type="button" id="delInfo">删除</button></th>
      	 </tr>
          <tr class="info text-center">
              <th rowspan="2" style="vertical-align: middle !important;text-align: center;"><input type="checkbox" id="checkAll"></th>
              <th rowspan="2" class="text-center">No.</th>
              <th rowspan="2" class="text-center">日期</th>
              <th colspan="1" class="text-center">供应商</th>
              <th colspan="2" class="text-center">收货方</th>
              <th rowspan="2" class="text-center">产品名称</th>
              <th rowspan="2" class="text-center">供货价(元)</th>
              <th rowspan="2" class="text-center">数量</th>
              <th rowspan="2" class="text-center">单位</th>
              <th rowspan="2" class="text-center">金额(元)</th>
              <th rowspan="2" class="text-center">批号/批次</th>
              <th rowspan="2" class="text-center">备注</th>
              <th rowspan="2" class="text-center">录入人</th>
              <th rowspan="2" class="text-center">录入时间</th>
              <th rowspan="2" class="text-center">销售人员</th>
              <th rowspan="2" class="text-center">操作</th>
          </tr>
          <tr class="info">
            <th class="text-center">经销商名称</th>
            <th class="text-center">系统名称</th>
            <th class="text-center">网点名称</th>
          </tr>
          <tbody>
          {volist name="data" id="list"}
              <tr>
              		<td align="center"><input type="checkbox" value="{$list.id}" name="items"></td>
                    <td>{$i}</td>
                    <td>{$list.fy2Date}</td>
                    <td>{$list.jxs}</td>
                    <td>{$list.xt}</td>
                    <td>{$list.wd}</td>
                    <td>{$list.cp}</td>
                    <td><?php if(strstr($list['ghjMoney'],'.')) {echo $list['ghjMoney'];}else{echo ($list['ghjMoney']+0).'.00';} ?></td>
                    <td><?php if(strstr($list['ghNum'],'.')) {echo $list['ghNum'];}else{echo ($list['ghNum']+0).'.00';} ?></td>
                    <td>{$list.dw}</td>
                   	<td class="ObjectNum">{$list.money}</td>
                    <td>{$list.phpc}</td>
                    <td>{$list.des}</td>
                    <td>{$list.lrUser}</td>
                    <td>{$list.lrDate}</td>
                    <td>{$list.xsUser}</td>
                    <td><a href="javascript:;" class="stair_modify" onclick="edit({$list.id})">修改</a>&nbsp;<a href="javascript:;" class="delthis" onclick="del({$list.id})">删除</a>&nbsp;<a href="javascript:;" onclick="info({$list.id})">查看</a></td>
              </tr>
               {/volist}
          </tbody>
      </table>
      <h5 class="text-center">
            总共有{$count}条记录，第{$page}/{$maxpage}页，当前页：<input id="page" name="pages" type="text" style="width: 70px;" value="" class="form-control" />
          <button id="gopage" type="submit" style="height: 23px;">GO</button>&nbsp;&nbsp;<button id="fistpage" type="submit" onclick="$('#form_id').find('input').val('');" style="height: 23px;">首页</button>&nbsp;&nbsp; 每页显示
            <select id="pagesize" style="width: 70px" class="form-control select" name="limts">
            <option value='1'>1</option>
            <option value='5'>5</option>
            <option value='10'>10</option>
          </select>条
          <script>
              $('#pagesize').val("{$limit}");
          </script>
        </h5>

</form>
    </div>
    <script>
        //日期范围限制
        var start = {
            elem: '#start',
            format: 'YYYY/MM/DD',
            min: laydate.now(), //设定最小日期为当前日期
            max: '2099-06-16 23:59:59', //最大日期
            istime: true,
            istoday: false,
            choose: function (datas) {
                end.min = datas; //开始日选好后，重置结束日的最小日期
                end.start = datas //将结束日的初始值设定为开始日
            }
        };
        var end = {
            elem: '#end',
            format: 'YYYY/MM/DD',
            min: laydate.now(),
            max: '2099-06-16 23:59:59',
            istime: true,
            istoday: false,
            choose: function (datas) {
                start.max = datas; //结束日选好后，重置开始日的最大日期
            }
        };
        laydate(start);
        laydate(end);
        $(document).ready(function(){
            // $("#verifytable tbody tr td").find('.duigou')
          /*格式化数字金额*/
          var $ObjectNum =$(".ObjectNum");
             toNum($ObjectNum);
          /*为已生效的核销申请字体加粗*/
            var $duigou =$(".duigou");
             $duigou.parent().addClass("font-bold");

/*设置删除*/
        $("#delInfo").click(function() {
            // $("#alert_addNewZone").show();
            var $items = $("[name=items]:checkbox")
            if ($items.filter(':checked').length < 1) {
                sweetAlert("", "请选择要删除的数据！", "error");
            } else {
                var str = '';
                $items.each(function () {
                    if ($(this).is(':checked')) {
                        if (str == '') {
                            str = $(this).val();
                        } else {
                            str += ',' + $(this).val();
                        }
                    }
                });
                swal({
                    title: "",
                    text: "您确定要此删除所选数据吗？不可恢复！",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "确定",
                    cancelButtonText: "取消",
                    closeOnConfirm: true,
                    closeOnCancel: true
                }, function () {
                    $.post("{:url('Ashippingmanagement2/delAll')}", {id: str}, function (re) {
                        if (re.success) {
                            location.reload();
                        } else {
                            sweetAlert("", re.msg, "error");
                        }
                    });
                });
            }
        });

/*弹出隐藏的tr*/
          /*table表格操作*/
      $("#checkAll").click(function() {

            $("[name=items]:checkbox").prop("checked", $(this).prop("checked"));
            if ($("[name=items]:checkbox").prop("checked") != true) {
                // console.log($(this))
                $("[name=items]:checkbox").parents("tr").css("backgroundColor", "#fff")
            } else {
                $("[name=items]:checkbox").parents("tr").css("backgroundColor", "#f8f800")

            }
        })
        $("[name=items]:checkbox").click(function() {
            //定义一个临时变量，避免重复使用同一个选择器选择页面中的元素，提高程序效率
            // console.log(1)
            var $tmp = $("[name=items]:checkbox");
            if ($(this).prop("checked") != true) {
                // console.log($(this))
                $(this).parent().parent().css("backgroundColor", "#fff")
            } else {
                $(this).parent().parent().css("backgroundColor", "#f8f800")

            }
            //用filter()方法筛选出选中的复选框，并直接给CheckedAll赋值
            $("#checkAll").prop('checked', $tmp.length == $tmp.filter(':checked').length);

          })
        })
        /*修改二级出货*/
        function edit(id) {
            layer.open({
                type: 2,
                maxmin: true, //开启最大化最小化按钮
                area: ['800px', '500px'], //宽高
                title: "修改二级发运数据",
                content: '{:url("Ashippingmanagement2/editP")}?id='+id
            });
        }
        /*二级出货详情*/
        function info(id) {
            layer.open({
                type: 2,
                maxmin: true, //开启最大化最小化按钮
                area: ['800px', '500px'], //宽高
                title: "查看二级发运数据",
                content: '{:url("Ashippingmanagement2/infoP")}?id='+id
            });
        }
        /*删除*/
        function del(id){
            swal({
                          title: "",
                          text: "您确定删除该条信息吗？",
                          type: "warning",
                          showCancelButton: true,
                          confirmButtonColor: "#DD6B55",
                          confirmButtonText: "确定",
                          cancelButtonText: "取消",
                          closeOnConfirm: true,
                          closeOnCancel: true
                        },function(){
                          $.get('{:url("Ashippingmanagement2/del")}',{id:id},function (re){
                              if (re.success) {
                                  location.reload();
                              } else {
                                  sweetAlert("", re.msg, "error");
                              }
                          })
                        });
        }
        // $(".delthis").click(function(){
        //            var _this=$(this);
        //           swal({
        //           title: "",
        //           text: "您确定删除该条信息吗？",
        //           type: "warning",
        //           showCancelButton: true,
        //           confirmButtonColor: "#DD6B55",
        //           confirmButtonText: "确定",
        //           cancelButtonText: "取消",
        //           closeOnConfirm: true,
        //           closeOnCancel: true
        //         },function(){
        //           _this.parent().parent().remove();
        //         });
        //     });

    </script>
{/block}
